home *** CD-ROM | disk | FTP | other *** search
- import java.util.Random;
-
- public class FightObject {
- final int STAND = 0;
- final int WALK = 1;
- final int JUMP = 2;
- final int CROUCH = 3;
- final int ATTACK = 4;
- final int CROUCH_ATTACK = 5;
- final int HIT = 6;
- final int CROUCH_HIT = 7;
- FightCanvas parent;
- byte player = 0;
- static Random rand = new Random();
- // $FF: renamed from: x int
- int field_0;
- // $FF: renamed from: y int
- int field_1;
- int state;
- int interval;
- int walking;
- int stop_walking;
- int walk_state;
- int stand_state;
- boolean crouching;
- boolean jump_up;
- int jump_attack_state;
- int jump_pos;
- int attack_dur;
- int attack_type;
- int diff = 0;
- boolean blocking;
- boolean attacking = false;
- public byte energy = 25;
- public byte power = 3;
- public byte speed = 3;
- public byte jump = 10;
- public int direct = 1;
- int hit_dur;
- boolean hit_jump;
- // $FF: renamed from: id int
- int field_2 = 0;
- int id_e = 0;
- int attack_no = 0;
-
- public FightObject(FightCanvas var1, int var2) {
- this.parent = var1;
- this.player = (byte)var2;
- if (this.player == 1) {
- this.direct = -1;
- }
-
- this.diff = 0;
- this.init();
- }
-
- public void setSkills(byte[] var1) {
- this.energy = var1[0];
- this.power = var1[1];
- this.speed = var1[2];
- this.jump = var1[3];
- }
-
- public void dead() {
- this.state = 0;
- this.jump();
-
- for(int var1 = 0; var1 < 8; ++var1) {
- if (var1 == 5) {
- this.hit();
- }
-
- try {
- Thread.sleep(100L);
- } catch (Exception var3) {
- }
-
- this.run();
- if (this.player == 0) {
- this.parent.playerSpr.setPosition(this.field_0, this.field_1 - 20 - this.jump_pos);
- } else {
- this.parent.enemySpr.setPosition(this.field_0, this.field_1 - 20 - this.jump_pos);
- }
-
- this.parent.repaint();
- }
-
- }
-
- public int rand(int var1) {
- int var2 = rand.nextInt() % var1;
- if (var2 < 0) {
- var2 = -var2;
- }
-
- return var2;
- }
-
- public void cpuMove() {
- if (!this.isHit()) {
- switch (this.diff) {
- case 0:
- if (this.interval % 2 == 0) {
- return;
- }
- break;
- case 1:
- if (this.interval % 3 == 0) {
- return;
- }
- }
-
- if (this.parent.fightObject.field_0 > this.field_0 + Fight.bounds[this.id_e][2] - (48 - Fight.bounds[this.field_2][2]) + Fight.skills[this.field_2][2] * 3) {
- if (this.crouching) {
- this.crouchStart();
- }
-
- switch (this.rand(7)) {
- case 0:
- this.jump();
- this.stepRight();
- break;
- case 1:
- this.stepRight();
- break;
- case 2:
- this.jump();
- this.attack(1);
- break;
- default:
- return;
- }
- }
-
- if (this.parent.fightObject.attacking) {
- ++this.attack_no;
- if (this.rand(3) != 1) {
- if (this.rand(3) >= this.diff) {
- this.block();
- }
-
- return;
- }
-
- switch (this.rand(10)) {
- case 2:
- this.crouchStart();
- break;
- case 3:
- this.stepLeft();
- break;
- case 4:
- this.attack(0);
- break;
- case 5:
- this.attack(1);
- break;
- default:
- return;
- }
- } else {
- int var1 = this.rand(14);
- switch (var1) {
- case 0:
- case 1:
- case 2:
- if (this.crouching) {
- switch (this.rand(4)) {
- case 0:
- this.attack(0);
- return;
- case 1:
- this.attack(1);
- return;
- default:
- return;
- }
- } else {
- this.crouchStart();
- break;
- }
- case 3:
- this.stepLeft();
- break;
- case 4:
- case 5:
- this.attack(0);
- break;
- case 6:
- case 7:
- this.attack(1);
- break;
- case 8:
- case 9:
- this.jump();
- default:
- return;
- }
- }
-
- }
- }
-
- public void init() {
- this.state = 0;
- if (this.player == 0) {
- this.field_2 = Fight.players[0];
- this.id_e = Fight.players[this.parent.level + 1];
- this.field_0 = 50;
- this.field_1 = 48;
- } else {
- this.field_2 = Fight.players[this.parent.level + 1];
- this.id_e = Fight.players[0];
- this.field_0 = 0;
- this.field_1 = 48;
- }
-
- this.walk_state = 0;
- this.stand_state = 0;
- this.stop_walking = 0;
- this.jump_pos = 0;
- this.blocking = false;
- this.attacking = false;
- }
-
- public boolean isHit() {
- return this.state == 6 || this.state == 7;
- }
-
- public void checkRange() {
- if (this.player == 0 && this.field_0 < this.parent.enemySpr.getXPosition() + Fight.bounds[this.id_e][2] - (48 - Fight.bounds[this.field_2][2])) {
- this.field_0 = this.parent.enemySpr.getXPosition() + Fight.bounds[this.id_e][2] - (48 - Fight.bounds[this.field_2][2]);
- }
-
- if (this.player == 1 && this.field_0 > this.parent.playerSpr.getXPosition() - (Fight.bounds[this.id_e][2] - (48 - Fight.bounds[this.field_2][2]))) {
- this.field_0 = this.parent.playerSpr.getXPosition() - (Fight.bounds[this.id_e][2] - (48 - Fight.bounds[this.field_2][2]));
- }
-
- if (this.player == 0) {
- if (this.field_0 < -20) {
- this.field_0 = -20;
- }
-
- if (this.field_0 > 50) {
- this.field_0 = 50;
- }
- } else {
- if (this.field_0 < 0) {
- this.field_0 = 0;
- }
-
- if (this.field_0 > 65) {
- this.field_0 = 65;
- }
- }
-
- }
-
- static int abs(int var0) {
- return var0 < 0 ? -var0 : var0;
- }
-
- public void attack(int var1) {
- switch (this.state) {
- case 0:
- case 1:
- this.state = 4;
- this.attack_dur = 2;
- switch (var1) {
- case 0:
- this.attack_type = 0;
- return;
- case 1:
- this.attack_type = 1;
- return;
- default:
- return;
- }
- case 2:
- if (this.walking != 0) {
- this.jump_attack_state = 1;
- } else {
- this.jump_attack_state = 2;
- }
- break;
- case 3:
- this.state = 5;
- this.attack_dur = 3;
- switch (var1) {
- case 0:
- this.attack_type = 0;
- break;
- case 1:
- this.attack_type = 1;
- }
- }
-
- }
-
- public void block() {
- switch (this.state) {
- case 0:
- case 1:
- this.attack_dur = 6;
- this.state = 4;
- this.attack_type = 2;
- case 2:
- default:
- break;
- case 3:
- this.attack_dur = 6;
- this.state = 5;
- this.attack_type = 2;
- }
-
- }
-
- public void hit() {
- switch (this.state) {
- case 0:
- case 1:
- this.state = 6;
- this.hit_dur = 4;
- break;
- case 2:
- this.hit_jump = true;
- break;
- case 3:
- this.state = 7;
- this.hit_dur = 5;
- }
-
- }
-
- public void crouchStart() {
- if (this.state != 2) {
- if (this.crouching) {
- this.state = 1;
- this.crouching = false;
- } else {
- this.state = 3;
- this.crouching = true;
- }
-
- }
- }
-
- public void stepLeft() {
- this.walking = -1;
- if (this.state == 2) {
- this.walking = -3;
- }
-
- this.walk_state = 1;
- --this.stop_walking;
- }
-
- public void stepRight() {
- this.walking = 1;
- if (this.state == 2) {
- this.walking = 3;
- }
-
- this.walk_state = 0;
- --this.stop_walking;
- }
-
- public void walkReset() {
- if (this.crouching) {
- this.state = 3;
- } else if (this.walking == 0) {
- this.state = 0;
- } else {
- this.state = 1;
- }
-
- this.hit_jump = false;
- this.stop_walking = 0;
- }
-
- public void jump() {
- switch (this.state) {
- case 0:
- case 1:
- case 3:
- this.jump_up = true;
- this.jump_attack_state = 0;
- this.state = 2;
- this.crouching = false;
- break;
- case 2:
- default:
- this.jump_attack_state = 0;
- }
-
- }
-
- public void run() {
- ++this.interval;
- switch (this.state) {
- case 0:
- case 1:
- if (this.walking != 0) {
- this.state = 1;
- ++this.walk_state;
- if (this.stop_walking >= 0 && (this.walk_state + 1) % 2 == 0) {
- this.walking = 0;
- }
-
- this.field_0 += this.walking * this.speed;
- this.checkRange();
- } else {
- this.state = 0;
- if (this.interval % 2 == 0) {
- ++this.stand_state;
- }
- }
- break;
- case 2:
- if (this.hit_jump) {
- this.field_0 += this.speed * this.direct;
- }
-
- if (this.jump_up) {
- this.jump_pos += this.jump;
- if (this.jump_pos >= 2 * this.jump) {
- this.jump_up = false;
- ++this.jump_pos;
- }
- } else {
- this.jump_pos -= this.jump;
- if (this.jump_pos <= 0) {
- this.jump_pos = 0;
- this.walking = 0;
- this.walkReset();
- }
- }
-
- this.field_0 += this.walking * this.speed;
- case 3:
- default:
- break;
- case 4:
- --this.attack_dur;
- if (this.attack_dur == 0) {
- this.walkReset();
- }
- break;
- case 5:
- --this.attack_dur;
- if (this.attack_dur == 0) {
- this.walkReset();
- }
- break;
- case 6:
- this.field_0 += this.speed * this.direct;
- --this.hit_dur;
- if (this.hit_dur == 0) {
- this.walkReset();
- }
- break;
- case 7:
- --this.hit_dur;
- this.field_0 += this.speed * this.direct;
- if (this.hit_dur == 0) {
- this.walkReset();
- }
- }
-
- this.checkRange();
- this.attacking = false;
- if (this.state == 4 || this.state == 5) {
- if (this.attack_type == 2) {
- this.blocking = true;
- } else {
- this.blocking = false;
- this.attacking = true;
- }
- }
-
- if (this.jump_attack_state > 0) {
- this.attacking = true;
- }
-
- this.setPlayerFrame();
- }
-
- public void setPlayerFrame() {
- int var1 = 0;
- byte var2 = 0;
- switch (this.state) {
- case 0:
- var1 = this.stand_state % 2;
- var2 = 0;
- break;
- case 1:
- var1 = this.walk_state % 2 + 2;
- var2 = 0;
- break;
- case 2:
- if (this.hit_jump) {
- var1 = 7;
- } else {
- if (this.jump_up) {
- switch (this.jump_attack_state) {
- case 2:
- var1 = 14;
- break;
- default:
- var1 = 12;
- }
- } else {
- switch (this.jump_attack_state) {
- case 0:
- var1 = 13;
- break;
- case 1:
- var1 = 14;
- break;
- case 2:
- var1 = 15;
- }
- }
-
- var2 = 0;
- }
- break;
- case 3:
- var2 = 3;
- var1 = 8;
- break;
- case 4:
- if (this.attack_type == 0) {
- var2 = 1;
- }
-
- if (this.attack_type == 1) {
- var2 = 2;
- }
-
- var1 = this.attack_type + 4;
- break;
- case 5:
- if (this.attack_type == 0) {
- var2 = 4;
- }
-
- if (this.attack_type == 1) {
- var2 = 5;
- }
-
- var1 = this.attack_type + 9;
- break;
- case 6:
- var2 = 0;
- var1 = 7;
- break;
- case 7:
- var2 = 3;
- var1 = 12;
- }
-
- if (this.player == 0) {
- this.parent.playerSpr.setFrame(var1);
- this.parent.playerSpr.setCollisionRectangle(48 - Fight.bounds[this.field_2][var2 + 2], Fight.sizes[this.field_2] - Fight.bounds[this.field_2][var2 / 3], Fight.bounds[this.field_2][var2 + 2], Fight.bounds[this.field_2][var2 / 3]);
- } else {
- this.parent.enemySpr.setFrame(var1);
- this.parent.enemySpr.setCollisionRectangle(0, Fight.sizes[this.field_2] - Fight.bounds[this.field_2][var2 / 3], Fight.bounds[this.field_2][var2 + 2], Fight.bounds[this.field_2][var2 / 3]);
- }
-
- }
- }
-